1. Field of the Invention
The invention relates to Universal Serial Bus (USB), and more particularly to data transfer of a USB device.
2. Description of the Related Art
USB provides connection of a computer with up to 127 peripheral devices. Current three editions of USB specification are USB 1.0, 2.0, and 3.0 respectively with bandwidths of 1.5 Mbps, 12 Mbps, and 480 Mbps. Because the advantages of USB include high bandwidth, bidirectional communication, Plug and Play (PnP), and low cost, current electronic devices, such as portable storage devices and digital video or audio devices, are commonly equipped with USB interfaces for connection with computers. For example, flash disks, digital cameras, Personal Digital Assistants, and MP3 players are conventionally equipped with USB interfaces.
The USB specification for mass storage devices includes four independent data transmission standards, the most prevalent among which comprise bulk-only and Control-Bulk-Interrupt (CBI) transmission modes. Both stipulate basic methods for transferring data between a USB host and a USB device. The bulk-only transmission mode uses only a bulk endpoint to transfer data, and the CBI transmission mode uses a control endpoint, a bulk endpoint, and an interrupt endpoint to carry out data transfer.
Data transferred between a USB host and a USB device is categorized as common data, command block wrappers (CBW), and command status wrappers (CSW). A CBW contains commands issued from the USB host to the USB device and comprises 31 bytes, with ordinarily SCSI commands stored therein. After the USB device retrieves the SCSI commands from the CBW and executes the SCSI commands, the USB device reports the execution results of the commands to the USB host with a CSW, which comprises 13 bytes. The USB host then ascertains the correctness of command execution and determines whether to continue the data transmission.
When the bulk-only transmission mode is adopted to transfer data, an ordinary USB device uses only a bulk endpoint to transfer data with the USB host. When the USB host sends data to the USB device, data is first received by the bulk endpoint and then stored in the bulk endpoint buffer. Accordingly, if data is sent from the USB device to the USB host, data to be transmitted is first stored in the bulk endpoint buffer and then sent with the bulk endpoint. Because only the bulk endpoint is used to transmit or receive common data, CBWs, and CSWs under the bulk-only transmission mode, the bulk endpoint buffer requires repeated clearance for the storage of transmitted data and received data, delaying the transmission of data and degrading the performance of the entire USB system.